blob: e39b985bef2fe65d359e16152b8cff322016fd08 [file] [log] [blame]
Blink WPT Bot76b44c02020-08-03 14:07:001<!doctype html>
2<meta charset=utf-8>
3<title>RTCPeerConnection.prototype.iceGatheringState</title>
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6<script src="RTCPeerConnection-helper.js"></script>
7<script>
8'use strict';
9
10promise_test(async t => {
11 const pc1 = new RTCPeerConnection();
12 t.add_cleanup(() => pc1.close());
13 const pc2 = new RTCPeerConnection();
14 t.add_cleanup(() => pc2.close());
youennf6c623dc2021-09-14 06:59:4115 pc1.addTransceiver('audio', { direction: 'recvonly' });
Blink WPT Bot76b44c02020-08-03 14:07:0016 await initialOfferAnswerWithIceGatheringStateTransitions(
youennf6c623dc2021-09-14 06:59:4117 pc1, pc2);
Blink WPT Bot76b44c02020-08-03 14:07:0018 await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true}));
19 await iceGatheringStateTransitions(pc1, 'gathering', 'complete');
20 expectNoMoreGatheringStateChanges(t, pc1);
21 await pc1.setLocalDescription({type: 'rollback'});
22 await new Promise(r => t.step_timeout(r, 1000));
23}, 'rolling back an ICE restart when gathering is complete should not result in iceGatheringState changes');
24
25promise_test(async t => {
26 const pc = new RTCPeerConnection();
27 t.add_cleanup(() => pc.close());
youennf6c623dc2021-09-14 06:59:4128 pc.addTransceiver('audio', { direction: 'recvonly' });
Blink WPT Bot76b44c02020-08-03 14:07:0029 await pc.setLocalDescription(
youennf6c623dc2021-09-14 06:59:4130 await pc.createOffer());
Blink WPT Bot76b44c02020-08-03 14:07:0031 await iceGatheringStateTransitions(pc, 'gathering', 'complete');
32 await pc.setLocalDescription({type: 'rollback'});
33 await iceGatheringStateTransitions(pc, 'new');
34}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "complete"');
35
36promise_test(async t => {
37 const pc = new RTCPeerConnection();
38 t.add_cleanup(() => pc.close());
youennf6c623dc2021-09-14 06:59:4139 pc.addTransceiver('audio', { direction: 'recvonly' });
Blink WPT Bot76b44c02020-08-03 14:07:0040 await pc.setLocalDescription(
youennf6c623dc2021-09-14 06:59:4141 await pc.createOffer());
Blink WPT Bot76b44c02020-08-03 14:07:0042 await iceGatheringStateTransitions(pc, 'gathering');
43 await pc.setLocalDescription({type: 'rollback'});
44 // We might go directly to 'new', or we might go to 'complete' first,
45 // depending on timing. Allow either.
46 const results = await Promise.allSettled([
47 iceGatheringStateTransitions(pc, 'new'),
48 iceGatheringStateTransitions(pc, 'complete', 'new')]);
49 assert_true(results.some(result => result.status == 'fulfilled'),
50 'ICE gathering state should go back to "new", possibly through "complete"');
51}, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "gathering"');
52
53</script>